﻿using iBuproModel.Repositories.Classes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using iBuproModel;
using System.Linq;
using System.Collections.Generic;

namespace IBuproModel.Tests
{
    
    
    /// <summary>
    ///This is a test class for StudentFieldRepositoryTest and is intended
    ///to contain all StudentFieldRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StudentFieldRepositoryTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for StudentFieldRepository Constructor
        ///</summary>
        [TestMethod()]
        public void StudentFieldRepositoryConstructorTest()
        {
            StudentFieldRepository target = new StudentFieldRepository();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for AddStudentFieldToStudentPlan
        ///</summary>
        [TestMethod()]
        public void AddStudentFieldToStudentPlanTest1()
        {
            InitTest init = new InitTest();
            StudentFieldRepository target = new StudentFieldRepository(); 
            StudentField studentField = init.GetStudentField(); 
            StudentPlan plan = init.GetStudentPlan();
            int studentPlanId = plan.Id; 
            target.AddStudentFieldToStudentPlan(studentField, studentPlanId);
            target.SaveChanges();

            Assert.IsTrue(plan.StudentFields.Contains(studentField));
        }


        /// <summary>
        ///A test for GetStudentFieldsForStudentPlan
        ///</summary>
        [TestMethod()]
        public void GetStudentFieldsForStudentPlanTest()
        {
            InitTest init = new InitTest();
            StudentFieldRepository target = new StudentFieldRepository(); 
            StudentField studentField = init.GetStudentField(); 
            StudentPlan plan = init.GetStudentPlan();
            int studentPlanId = plan.Id; 
            target.AddStudentFieldToStudentPlan(studentField, studentPlanId);
            target.SaveChanges();

            Assert.IsNotNull(plan.StudentFields);
            
        }

        /// <summary>
        ///A test for Hide
        ///</summary>
        [TestMethod()]
        public void HideTest()
        {
            InitTest init = new InitTest();
            StudentFieldRepository target = new StudentFieldRepository(); 
            StudentField studentField = init.GetStudentField(); 
            target.Hide(studentField.Id);
            Assert.AreEqual(studentField.Visible, false);
        }

        /// <summary>
        ///A test for UpdateSubjectList
        ///</summary>
        [TestMethod()]
        public void UpdateSubjectListTest()
        {
            try
            {
                InitTest init = new InitTest();
                StudentFieldRepository target = new StudentFieldRepository();
                    
                StudentField studentField = init.GetStudentField(); 
                List<int> ids = new List<int>(); 
                ids.Add(studentField.Id);
                target.UpdateSubjectList(studentField, ids);
            }
            catch (Exception)
            {

                Assert.Fail();
            }

        }
    }
}
